<template>
  <div class="icon" @click="onToggle">
    <Icon
      :type="isFullscreen ? 'FullscreenExitOutlined' : 'FullscreenOutlined'"
    />
  </div>
</template>
<script setup>
import Icon from '@/components/Icon'
import { onMounted, ref, onUnmounted } from 'vue'
import screenfull from 'screenfull'

// 是否全屏
const isFullscreen = ref(false)
const onToggle = () => {
  screenfull.toggle()
}
// 监听全屏
const change = () => {
  isFullscreen.value = screenfull.isFullscreen
}
onMounted(() => {
  screenfull.on('change', change)
})

onUnmounted(() => {
  screenfull.off('change', change)
})
</script>
<style scoped lang="scss">
.icon {
  height: 100%;
  width: 100%;
}
</style>
